package von.seiji.cn;

import von.seiji.cn.asset.$Proxy;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Proxy;

/**
 * @author SeiJi
 */
public class ProxyUtil {

    public static void execute(String className) throws ClassNotFoundException
            , NoSuchMethodException, IllegalAccessException, InstantiationException, InvocationTargetException {
        Class<?> aClass = Class.forName(className);
        Object instance = Proxy.newProxyInstance(ProxyUtil.class.getClassLoader()
                , aClass.getInterfaces(), (proxy, method, args) ->
                        method.invoke(aClass.newInstance(), args)
        );
        $Proxy proxy = $Proxy.class.cast(instance);
        proxy.execute();
    }
}
